package com.example.servlet;
import com.example.dao.NovelDao;
import com.example.dao.UserDao;
import com.example.domain.Novel;
import com.example.domain.User;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@WebServlet("/AdminNovelSearchServlet")
public class AdminNovelSearchServlet extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException{
        request.setCharacterEncoding("utf-8");
        String keyword=request.getParameter("keyword");
        NovelDao novelDao=new NovelDao();
        List<Novel> novelList=novelDao.getNovelBySearchCount(keyword);
        if(novelList==null){
            request.setAttribute("msg","没有找到相关小说");
            request.getRequestDispatcher("admin_Novel.jsp").forward(request, response);
            return;
        }
        request.setAttribute("novelList",novelList);
        request.getRequestDispatcher("admin_Novel.jsp").forward(request,response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException{
        doGet(request,response);
    }
}
